package com.example.contact;

import java.util.HashMap;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

public class DetailActivity extends Activity {
	
	EditText et_name;
	EditText et_mobilephone;
	EditText et_familyphone;
	EditText et_officePhone;
	EditText et_position;
	EditText et_company;
	EditText et_address;
	EditText et_zipcode;
	EditText et_email;
	EditText et_otherContact;
	EditText et_remark;
	
	ImageButton btn_img;

	protected void onCreate(Bundle savedInstanceState) {
	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.detail);
		initWidget();
		Intent intent = getIntent();
		HashMap map = (HashMap)intent.getSerializableExtra("usermap");
		displayData(map);
	}

	
	public void initWidget() {
		et_name = (EditText) this.findViewById(R.id.et_name);
		et_mobilephone = (EditText) this.findViewById(R.id.et_mobilephone);
		et_familyphone = (EditText) this.findViewById(R.id.et_familyphone);
		et_officePhone = (EditText) this.findViewById(R.id.et_officephone);
		et_position = (EditText) this.findViewById(R.id.et_position);
		et_company = (EditText) this.findViewById(R.id.et_company);
		et_address = (EditText) this.findViewById(R.id.et_address);
		et_zipcode = (EditText) this.findViewById(R.id.et_zipcode);
		et_email = (EditText) this.findViewById(R.id.et_email);
		et_otherContact = (EditText) this.findViewById(R.id.et_other);
		et_remark = (EditText) this.findViewById(R.id.et_remark);
		
		btn_img = (ImageButton)findViewById(R.id.btn_img);
	}
	
	private void displayData(HashMap map) {
		et_name.setText(String.valueOf(map.get("name")));
		et_mobilephone.setText(String.valueOf(map.get("mobilephone")));
		et_familyphone.setText(String.valueOf(map.get("familyphone")));
		et_officePhone.setText(String.valueOf(map.get("officephone")));
		et_position.setText(String.valueOf(map.get("position")));
		et_company.setText(String.valueOf(map.get("company")));
		et_address.setText(String.valueOf(map.get("address")));
		et_zipcode.setText(String.valueOf(map.get("zipcode")));
		et_email.setText(String.valueOf(map.get("email")));
		et_otherContact.setText(String.valueOf(map.get("othercontact")));
		et_remark.setText(String.valueOf(map.get("remark")));
		btn_img.setImageResource(Integer.parseInt(String.valueOf(map.get("imageid"))));
		
	}
	
}
